package com.zhang.shopcar.utils;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * Created by Administrator on 2016/4/15.
 */
public class SPUtils {
    private SharedPreferences mSp;
    private SharedPreferences.Editor mEditor;

    public SPUtils(Context context) {
        mSp = context.getSharedPreferences("xinkeqi", Context.MODE_PRIVATE);
        mEditor = mSp.edit();
    }

    /**取出string*/
    public String getString(String key, String defValue) {
        return mSp.getString(key, defValue);
    }

    /**取出int*/
    public int getInt(String key, int defValue) {
        return mSp.getInt(key, defValue);
    }

    /**取出boolean*/
    public boolean getBoolean(String key, boolean defValue) {
        return mSp.getBoolean(key, defValue);
    }

    /**存入string*/
    public void putString(String key, String value) {
        mEditor.putString(key, value);
        mEditor.commit();

    }

    /**存入int*/
    public void putInt(String key, int value) {
        mEditor.putInt(key, value);
        mEditor.commit();
    }

    /**存入boolean*/
    public void putBoolean(String key, boolean value) {
        mEditor.putBoolean(key, value);
        mEditor.commit();
    }
    /**存入long*/
    public void putLong(String key, long value) {
        mEditor.putLong(key, value);
        mEditor.commit();
    }
    public long getLong(String key, int defValue) {
        return mSp.getLong(key, defValue);
    }

    /**存入long*/
    public void putFloat(String key, float value) {

        mEditor.putFloat(key, value);
        mEditor.commit();
    }
    public float getFloat(String key, float defValue) {
       return mSp.getFloat(key,defValue);
    }




}
